package my_sql;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import my_sql.Student;

import uilt.DBUtil;

import my_sql.StudentDao;

public class StudentAdd implements StudentDao {

	@Override
	public Student login(String sname, String pass,int gradeid) {
		PreparedStatement st = null;
		ResultSet rs = null;

		String sql = "insert into `student`(sname,pass,gradeid)";
		sql += "values(?,?,?)";

		Connection con = DBUtil.open();

		Student s = null;

		try {
			st = con.prepareStatement(sql);
			st.setString(1, sname);
			st.setString(2, pass);
			st.setInt(3, gradeid);
			st.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}finally {
			DBUtil.close(st, con, rs);
		}
		return s;

		
		
		
	}
}
